<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>公司简介</title>
        <link rel="stylesheet" type="text/css" href="<%=path%>sys/css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="<%=path%>sys/easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="<%=path%>sys/easyui/themes/icon.css">
        <link rel="stylesheet" type="text/css" href="<%=path%>sys/easyui/demo/demo.css">
        <link rel="stylesheet" type="text/css" href="<%=path%>sys/css/dropzone.css">
        <script type="text/javascript" src="<%=path%>sys/easyui/jquery.min.js"></script>
        <script type="text/javascript" src="<%=path%>sys/easyui/jquery.easyui.min.js"></script>
        <script src="<%=path%>sys/js/dropzone.js"></script>
        <script type="text/javascript" src="<%=path%>sys/js/autoHeight.js"></script>
    </head>
    <style type="text/css">
		html{
			height:100%
		}
		body{
			height:100%;
		}
        .ftitle 
        { 
            font-size: 14px; 
            font-weight: bold; 
            padding: 5px 0; 
            margin-bottom: 10px; 
            border-bottom: 1px solid #ccc; 
        } 
        .fitem 
        { 
           margin-bottom: 5px;
        } 
        .fitem label 
        { 
          display: inline-block; 
          width: 100px;
          text-align:right;
        }
       	/* 用户管理页面样式  */
       #chaxun{
       		margin:10px 10px 10px 4px;
       }
       #chaxun span.l-btn-left{       		
       		background:#4FAAF1
       }
        #chaxun span.l-btn-text{
        	color:#fff
        }
        #chaxun span.l-btn-left:hover{
        	background:	#FF8C30
        }
        #toolbar{
        	margin-top:20px;
        }
		#baocun span span.l-btn-text,#quxiao span span.l-btn-text,#baocun1 span span.l-btn-text,#quxiao1 span span.l-btn-text{
			color:#000;
		}
		.window{
			background:#0D5163;
			color:#fff;
		}
		.div-title {
			margin: 0;
			height: 30px;
			line-height: 30px;
			font-weight: normal;
			font-size: 14px;
			text-indent: 10px;
			background: #0e92df;
			color:#fff;
			font-family:"微软雅黑";
		}
		.content {
			padding-bottom:0px;
		}
		.datagrid-toolbar{
			padding-left:5px;
		}
		.new_table{
			border:1;
		}
		.new_table tbody{
			width:100%;
			
		}
		.new_table tr{
			border-bottom:1px solid #ccc;
			
			width:100%
		}
		.new_table tr table tr{
			border:none;
		}
		.edit_dialog li{      		
      		margin:15px 0;
      	}
		.table th, .table td{
			color:#fff;
			font-family:"Microsoft Yahei";
		}
    </style>
    <body>
       	 <!--主题内容-->
		<div class="content" style="height:100%;">
			<!--操作面板 开始-->
			<div class="news" id="c1_1" style="height: auto;border:1px solid #e0d6d6;float:none;width:99%;margin:10px auto 15px;">
				<div id="tb" style="padding:2px 5px;margin:10px 0;">
					<div class="input-prepend">
						<span class="add-on" style="color: #333">组织名称</span>
						<input id="comName" class="easyui-text" style="width: 100px;height:25px">
					</div>
					<button type="button" class="btn btn-info" id="search">查询</button>
				</div>
			</div>
			<!--操作面板 结束 -->
			<!--数据表格-->
			<div autoheight="100" style="width:99%;margin:0 auto;">
				<table id="dataGrid" style="width:100%;height:100%"></table>
			</div>
			<!--+++++++++++++++++++数据添加、编辑弹出框+++开始++++++++++++++++-->
			<div id="add" class="easyui-dialog" style=" padding: 10px 20px;width: 600px;height: 400px;" closed="true" buttons="#add-buttons"> 
				<div class="fitem" style="padding-right:10px">
					<label>公司名称：</label>
					<input name="inputUser" id="inputUserId" class="easyui-textbox" style="width:300px" data-options="required:true,validType:'length[1,30]'"/>
				</div>
				<div class="fitem">
					<label>公司简介：</label>
					<textarea name="servicePlanContent" class="textarea easyui-validatebox"  style="width:300px;margin-top:4px;font-size:14px;" rows="3" cols="30"></textarea>
				</div>
				<div class="fitem">
					<form action="<%=path%>companyInfo/imgUpLoad.action" class="dropzone" ></form>
				</div>
		   </div> 
			<div id="add-buttons"> 
				<span style="float: left;margin-left: 200px;color: red;" id="result_sp"></span>
		        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="saveuser()" iconcls="icon-save" id="baocun">保存</a> 
		        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#add').dialog('close')" iconcls="icon-cancel" id="quxiao">取消</a> 
		    </div> 
		<!--+++++++++++++++++++数据添加、编辑弹出框+++结束++++++++++++++++-->
		</div>
    </body>
    <script type="text/javascript">
        $(function(){
            initTable();
        })
        
	    function initTable(){
	    	$(".content").auto(true);
			$("#dataGrid").datagrid({
				url:'<%=path%>companyInfo/getTableData.action',
				method:'post',
				width:'100%',
				rownumbers:true,
				singleSelect:true,
				fitColumns:true,
				pagination:true,
				onLoadSuccess:function(data){
				},
				columns:[[{field:'ID',title:'唯一表示',width:0,align:'center',hidden:true},
	                      {field:'COM_NAME',title:'公司名称',width:60,align:'center'},
					      {field:'IMG_PATH',title:'图片路径',width:120,align:'center'},
					      {field:'PROFILE',title:'公司简介',width:80,align:'center'},
					      {field:'EDTM',title:'操作时间',width:70,align:'center'}
					    ]],
				toolbar:[
	                  {text:"增加",iconCls:"icon-add",handler:function(){	
	                	  $("#add").dialog("open").dialog('setTitle', '新增系列');				//打开添加面板
	                  }},
	                  {text:"删除",iconCls:"icon-remove",handler:function(){
	                    var row = $('#limitGrid').datagrid('getSelected');
	                    if(row==null) return $.messager.alert("提示信息", "当前没有选中记录！");
	       	            if(row!=null&&row.opt!=0){
	       	                $.messager.confirm('提示信息','确定删除吗?', function (r) {
	       					if (r) {
	       	                        $.messager.alert("提示信息", "删除成功");
	       	                    }
	       	                });
	       	            }else{
	       	            	$.messager.alert("提示信息", "记录当前状态不能被删除！");
	       	            }
	                  }},
	                  {text:"修改",iconCls:"icon-edit",handler:function(){  
	                      var row = $('#limitGrid').datagrid('getSelected');
	                      if(row==null) return $.messager.alert("提示信息", "当前没有选中记录！");
	                	  $.messager.alert("提示信息", "暂时没做，和添加页面基本一样！");
	                  }}
				],
	          queryParams:{
	        	  comName:$("#comName").val()
	          }
			});
		   
		   var p = $('#dataGrid').datagrid('getPager'); 
	          $(p).pagination({ 
	              pageSize: 10,//每页显示的记录条数，默认为10
	              pageList:[10,15,20],//每页显示几条记录
	              beforePageText: '第',//页数文本框前显示的汉字
	              afterPageText: '页    共 {pages} 页',
	              displayMsg: '当前显示 {from} - {to} 条记录    共 {total} 条记录',
	              onBeforeRefresh:function(){ 
	                  $(this).pagination('loading');//正在加载数据中...
	                  $(this).pagination('loaded'); //数据加载完毕
	              } 
	          }); 
		}
	        
		//保存方法
		function saveuser(){
	        $("#fm").form("submit", {
	            url: '<%=path %>companyInfo/save.action',
	            success: function (result) {
	            	console.log(result);
	            	if (result='success') {
	                    $.messager.alert("提示信息","操作成功");
	                    $("#add").dialog("close");		    //关闭操作窗口
	                    $("#dataGrid").datagrid("load");	//重新加载表格
	                } else {
	                    $.messager.alert("提示信息", "操作的失败了");
	                }
	            }
	        });
	    }
	        
	    $("#dropz").dropzone({
	        method:"post",  //也可用put
	        paramName:"Filedata", //默认为file
	        maxFiles:1,//一次性上传的文件数量上限
	        maxFilesize: 0.1, //MB
	        acceptedFiles: ".jpg,.gif,.png", //上传的类型
	        addRemoveLinks:true,
	        parallelUploads: 1,
	        init:function(){
	            this.on("addedfile", function(file) { 
	            //上传文件时触发的事件
	            });
	            this.on("queuecomplete",function(file) {
	                //上传完成后触发的方法
	            });
	            this.on("removedfile",function(file){
	                //删除文件时触发的方法
	            });
	        }
	    });
    </script>
</html>